<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root"></div>
<script src="../../javascript/react.development.js"></script>
<script src="../../javascript/react-dom.development.js"></script>
<script src="../../javascript/babel.min.js"></script>
<script type="text/babel">
    class App extends React.Component {
        constructor(props, context) {
            super(props, context)
            this.state = {userName: "", password: ""}
        }

        render() {
            const {userName, password} = this.state
            return (
                <div className="app">
                    <form>
                        <input type="text" value={userName} onChange={event => this.saveFormData("userName", event.target.value)}/>
                        <input type="text" value={password} onChange={event => this.saveFormData("password", event.target.value)}/>
                        <button>登录</button>
                    </form>
                </div>
            );
        }
        saveFormData = (dataType, value) => {
            this.setState({[dataType]: value})
        }
    }
    ReactDOM.render(<App></App>, document.querySelector("#root"))
</script>
</body>
</html>